package comWorld.listener;

import javax.servlet.ServletRequestAttributeEvent;
import javax.servlet.ServletRequestAttributeListener;
import javax.servlet.annotation.WebListener;
import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionBindingEvent;

import comWorld.user.UserInfo;
import comWorld.user.UserUrls;

/**
 * Application Lifecycle Listener implementation class RequestAttr
 *
 */
@WebListener
public class RequestAttr implements ServletRequestAttributeListener {

    /**
     * Default constructor. 
     */
    public RequestAttr() {
    }

	/**
     * @see ServletRequestAttributeListener#attributeRemoved(ServletRequestAttributeEvent)
     */
    public void attributeRemoved(ServletRequestAttributeEvent event)  { 
    }

	/**
     * @see ServletRequestAttributeListener#attributeAdded(ServletRequestAttributeEvent)
     */
    public void attributeAdded(ServletRequestAttributeEvent event)  { 
    	 urlAdjust(event);
    }

	/**
     * @see ServletRequestAttributeListener#attributeReplaced(ServletRequestAttributeEvent)
     */
    public void attributeReplaced(ServletRequestAttributeEvent event)  { 
    	urlAdjust(event);
    }
	
    private void urlAdjust(ServletRequestAttributeEvent event) {
    	Object obj = event.getValue();
//		if (obj instanceof UserUrls) {
//			UserUrls userUrls = (UserUrls) obj;
//			userUrls.setRootPath(event.getServletContext()
//					.getInitParameter("webRootUrl"));
//		}
    }
}
